package spring.条件注册bean;

import common.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MainConfig {
    @Bean("person")
    public Person person() {
        System.out.println("给容器中添加person.......");
        return new Person("person", 20);
    }

    @Conditional(WinCondition.class)
    @Bean
    public Person lison() {
        System.out.println("给容器中添加person.......");
        return new Person("person", 58);
    }

    @Conditional(LinCondition.class)
    @Bean//bean在容器中的ID为james, IOC容器MAP,  map.put("id",value)
    public Person james() {
        System.out.println("给容器中添加person.......");
        return new Person("person", 20);
    }

}
